local quanqing = fk.CreateSkill{
  name = "n_quanqing",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["n_quanqing"] = "权倾",
  [":n_quanqing"] = "锁定技，当一名角色失去最后的手牌后，你摸一张牌，并令本局你的摸牌阶段摸牌数+1（至多+10）。",
}

quanqing:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(quanqing.name) then return end
    local x = 0
    for _, move in ipairs(data) do
      if move.from and move.from:isKongcheng() then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand then
            return true
            -- x = x + 1
          end
        end
      end
    end
    -- if x > 0 then
    --   event:setCostData(self, { extra_data = x })
    --   return true
    -- end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    -- player:drawCards(event:getCostData(self).extra_data, quanqing.name)
    player:drawCards(1, quanqing.name)
    if player:getMark(quanqing.name) < 10 then
      room:addPlayerMark(player, quanqing.name)
    end
  end,
})

--[[
quanqing:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(quanqing.name) and player.phase == Player.Draw and
      player:getMark(quanqing.name) < 10 and
      table.find(player.room.alive_players, function(p)
        return p:isKongcheng()
      end)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
  end,
})
--]]

quanqing:addEffect(fk.DrawNCards, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:getMark(quanqing.name) > 0
  end,
  on_use = function(self, event, target, player, data)
    data.n = data.n + player:getMark(quanqing.name)
  end,
})

return quanqing
